<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="../TemplateAdmin.xhtml">
        <ui:define name="title">
            <h:outputText value="Create Manaer"></h:outputText>
        </ui:define>       
        <ui:define name="body">
            <h:form>
                <p:panel>              
                    <p:panelGrid columns="3" >
                        <f:facet name="header">
                            <b>Create New Manager</b>
                        </f:facet>
                        <p:messages id="msgs"/> 
                        <h:outputLabel value="Name :" for="mnName" />
                        <p:inputText id="mnName" value="#{managerController.selected.mnName}" title="Name" 
                                     required="true" requiredMessage="The Name field is required"/>
                        <p:message id="NameMessage" for="mnName" display="text"/> 

                        <h:outputLabel value="UserName :" for="mnUserName" /> 
                        <p:inputText id="mnUserName" value="#{managerController.selected.mnUserName}" title="UserName" 
                                     required="true" requiredMessage="The UserName field is required">                        
                            <f:validateLength minimum="6" maximum="10" /> 
                        </p:inputText>
                        <p:message id="UserNameMessage" for="mnUserName" display="text"/> 

                        <h:outputLabel value="Password :" for="mnPassword" />
                        <p:password id="password1" match="password2" feedback="false" value="#{managerController.selected.mnPassword}" title="Password" 
                                    required="true" requiredMessage="The Password field is required">
                            <f:validateLength  maximum="10" />
                        </p:password>
                        <p:message id="passwordMessage" for="password1" display="text"/>

                        <h:outputLabel value="Password Confirm :" for="mnPassword" />
                        <p:password id="password2" feedback="false" value="#{managerController.selected.mnPassword}" title="Password" 
                                    required="true" requiredMessage="The Password Confirn field is required"/>                     
                        <p:message id="passwordMessage2" for="password2" display="text"/>  

                        <h:outputLabel value="Email" for="mnEmail" />
                        <p:inputText id="mnEmail" value="#{managerController.selected.mnEmail}" title="Email" required="true" 
                                     requiredMessage="The Email  field is required">
                            <!-- viết biểu thức phù hợp -->
                            <!--  <f:validateRegex pattern="^[a-zA-Z]" /> -->
                        </p:inputText>
                        <p:message id="mnEmailMessage" for="mnEmail" display="text"/> 

                        <h:outputLabel value="Address :" for="mnAdress" />
                        <p:inputText id="mnAdress" value="#{managerController.selected.mnAdress}" title="Address" />
                        <h:panelGroup/>

                        <h:outputLabel value="Phone" for="mnPhone" />
                        <p:inputText id="mnPhone" value="#{managerController.selected.mnPhone}" title="Phone" required="true" 
                                     requiredMessage="The Phone field is required.">
                            <!-- viết biểu thức phù hợp (chỉ được nhập sô -->
                            <!-- <f:validateRegex pattern="^[a-zA-Z]" /> -->
                        </p:inputText>
                        <p:message id="phoneMessage" for="mnPhone" display="text"/> 

                        <h:outputLabel value="Status :" for="mnStatus" />
                        <p:selectOneRadio id="usStatus" value="#{managerController.selected.mnStatus}">  
                            <f:selectItem itemLabel="True" itemValue="1" />  
                            <f:selectItem itemLabel="False" itemValue="0" /> 
                        </p:selectOneRadio> 
                        <h:panelGroup/>
                        <h:outputLabel value="Permission :" for="mnPermission" /> 
                        <p:selectOneMenu value="#{managerController.selected.mnPermission}" id="mnPermission" style="width: 100%">   
                            <f:selectItem itemLabel="Select One" itemValue="" />
                            <f:selectItem itemLabel="Admin" itemValue="0" />
                            <f:selectItem itemLabel="Staff Order" itemValue="1" />  
                            <f:selectItem itemLabel="Staff Project" itemValue="2" /> 
                        </p:selectOneMenu>
                        <h:panelGroup/>
                        <f:facet name="footer">
                            <br />
                        </f:facet>
                    </p:panelGrid>
                    <p:commandButton action="#{managerController.create}" value="Save" icon="ui-icon-check" />
                    <p:commandButton action="#{managerController.prepareList}" value="View All" immediate="true"  icon="ui-icon-script"/>
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

